import smtplib #用于邮件的发信动作
from email.mime.text import MIMEText #邮件内容支持纯文本、HTML
from email.mime.image import MIMEImage #邮件内容支持图片
from email.mime.multipart import MIMEMultipart #邮件内容支持附件
from email.mime.application import MIMEApplication
from email.header import Header #用于构建邮件头
addr = "台式机"
sender_addr= "3527350003@qq.com"
psd = "qmkanyrqdixcchah"
receiver_addr="592199007@qq.com"
smtp_server = "smtp.qq.com"

try:
    smtpobj = smtplib.SMTP_SSL(smtp_server)
    smtpobj.connect(smtp_server,465)
    smtpobj.login(sender_addr,psd)
    print("邮件服务开启成功")
except smtplib.SMTPException as ex:
    print("邮件服务开启失败")
finally:
    smtpobj.quit()

def sendMsg(my_msg):
    '''msg = MIMEText("来自"+addr,"plain","utf-8")
    msg['From'] = Header("3527350003@qq.com")
    msg['To'] = Header("admin")
    msg['subject'] = Header(my_msg,'utf-8')

    try:
        smtpobj = smtplib.SMTP_SSL(smtp_server)
        smtpobj.connect(smtp_server,465)
        smtpobj.login(sender_addr,psd)
        smtpobj.sendmail(sender_addr,receiver_addr,msg.as_string())
        print("邮件发送成功")
    except smtplib.SMTPException as ex:
        print("邮件发送失败")
    finally:
        smtpobj.quit()'''

